package yu.vert.queue;

import java.util.concurrent.DelayQueue;

/**
 * 一个简单的延时记录获取
 */
public class QueueTestMain {

    public static void main(String[] args) {
        DelayQueue<MyUser> userDelayQueue = new DelayQueue<>();
        MyUser myUser = new MyUser("a1", System.currentTimeMillis() + 10000);
        userDelayQueue.add(myUser);
        while (true) {
            try {
                System.out.println(userDelayQueue.size());
                MyUser take = userDelayQueue.take();
                System.out.println(take.getId());
                System.out.println(userDelayQueue.size());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

}
